package com.hjh.netty.elect.demo4;

import com.hjh.netty.elect.util.NumberDataConvertUtils;
import org.springframework.stereotype.Service;

/**
 * 自定义测点数据 解析(子类=0x01，版本=2)
 * @author pyz
 *
 */
@Service("analysisCustomizeUpLoadDataService")
public class AnalysisCustomizeUpLoadDataService implements AnalysisUpLoadDataService{

	@Override
	public SubType1TypeVer2 analysisUpLoadData(String upLoadData) {
		int index = 0;
		SubType1TypeVer2 result = new SubType1TypeVer2();
		//装置序列号  格式：uint32，单位：
		String deviceSn = upLoadData.substring(index, index + 8);
		result.setDeviceSn(NumberDataConvertUtils.hexString2decimalInt(deviceSn));
		index += 8;
		//DI 状态  格式：uint16，单位：
		String DIStatus = upLoadData.substring(index, index + 4);
		result.setDeviceSn(NumberDataConvertUtils.hexString2decimalInt(DIStatus));
		index += 4;
		//DO 状态  格式：uint16，单位：
		String DOStatus = upLoadData.substring(index, index + 4);
		result.setDOStatus(NumberDataConvertUtils.hexString2decimalInt(DOStatus));
		index += 4;
		//告警状态  格式：uint16，单位：
		String AlarmStatus = upLoadData.substring(index, index + 4);
		result.setAlarmStatus(NumberDataConvertUtils.hexString2decimalInt(AlarmStatus));
		index += 4;
		//预警状态  格式：uint16，单位：
		String PreAlarmStatus = upLoadData.substring(index, index + 4);
		result.setPreAlarmStatus(NumberDataConvertUtils.hexString2decimalInt(PreAlarmStatus));
		index += 4;
		//越限状态  格式：uint16，单位：
		String setpointStatus = upLoadData.substring(index, index + 4);
		result.setSetpointStatus(NumberDataConvertUtils.hexString2decimalInt(setpointStatus));
		index += 4;
		//Ir 故障状态  格式：uint16，单位：
		String IRCheckStatus = upLoadData.substring(index, index + 4);
		result.setIRCheckStatus(NumberDataConvertUtils.hexString2decimalInt(IRCheckStatus));
		index += 4;
		//TC 故障状态  格式：uint16，单位：
		String TCCheckStatus = upLoadData.substring(index, index + 4);
		result.setTCCheckStatus(NumberDataConvertUtils.hexString2decimalInt(TCCheckStatus));
		index += 4;
		//Ia  格式：float，单位：A
		String I1 = upLoadData.substring(index, index + 8);
		result.setI1(NumberDataConvertUtils.hexFloatString2decimalFloatString(I1));
		index += 8;
		//Ib  格式：float，单位：A
		String I2 = upLoadData.substring(index, index + 8);
		result.setI2(NumberDataConvertUtils.hexFloatString2decimalFloatString(I2));
		index += 8;
		//Ic  格式：float，单位：A
		String I3 = upLoadData.substring(index, index + 8);
		result.setI3(NumberDataConvertUtils.hexFloatString2decimalFloatString(I3));
		index += 8;
		//Pa  格式：float，单位：W
		String Pa = upLoadData.substring(index, index + 8);
		result.setPa(NumberDataConvertUtils.hexFloatString2decimalFloatString(Pa));
		index += 8;
		//Pb  格式：float，单位：W
		String Pb = upLoadData.substring(index, index + 8);
		result.setPb(NumberDataConvertUtils.hexFloatString2decimalFloatString(Pb));
		index += 8;
		//Pc  格式：float，单位：W
		String Pc = upLoadData.substring(index, index + 8);
		result.setPc(NumberDataConvertUtils.hexFloatString2decimalFloatString(Pc));
		index += 8;
		/** 电压 **/
		//A 相电压HD3
		String AUHD3 = upLoadData.substring(index, index + 8);
		result.setAUHD3(NumberDataConvertUtils.hexFloatString2decimalFloatString(AUHD3));
		index += 8;
		//B 相电压HD3
		String BUHD3 = upLoadData.substring(index, index + 8);
		result.setBUHD3(NumberDataConvertUtils.hexFloatString2decimalFloatString(BUHD3));
		index += 8;
		//C 相电压HD3
		String CUHD3 = upLoadData.substring(index, index + 8);
		result.setCUHD3(NumberDataConvertUtils.hexFloatString2decimalFloatString(CUHD3));
		index += 8;
		//A 相电压HD5
		String AUHD5 = upLoadData.substring(index, index + 8);
		result.setAUHD5(NumberDataConvertUtils.hexFloatString2decimalFloatString(AUHD5));
		index += 8;
		//B 相电压HD5
		String BUHD5 = upLoadData.substring(index, index + 8);
		result.setBUHD5(NumberDataConvertUtils.hexFloatString2decimalFloatString(BUHD5));
		index += 8;
		//C 相电压HD5
		String CUHD5 = upLoadData.substring(index, index + 8);
		result.setCUHD5(NumberDataConvertUtils.hexFloatString2decimalFloatString(CUHD5));
		index += 8;
		//A 相电压HD7
		String AUHD7 = upLoadData.substring(index, index + 8);
		result.setAUHD7(NumberDataConvertUtils.hexFloatString2decimalFloatString(AUHD7));
		index += 8;
		//B 相电压HD7
		String BUHD7 = upLoadData.substring(index, index + 8);
		result.setBUHD7(NumberDataConvertUtils.hexFloatString2decimalFloatString(BUHD7));
		index += 8;
		//C 相电压HD7
		String CUHD7 = upLoadData.substring(index, index + 8);
		result.setCUHD7(NumberDataConvertUtils.hexFloatString2decimalFloatString(CUHD7));
		index += 8;
		//A 相电压HD9
		String AUHD9 = upLoadData.substring(index, index + 8);
		result.setAUHD9(NumberDataConvertUtils.hexFloatString2decimalFloatString(AUHD9));
		index += 8;
		//B 相电压HD9
		String BUHD9 = upLoadData.substring(index, index + 8);
		result.setBUHD9(NumberDataConvertUtils.hexFloatString2decimalFloatString(BUHD9));
		index += 8;
		//C 相电压HD9
		String CUHD9 = upLoadData.substring(index, index + 8);
		result.setCUHD9(NumberDataConvertUtils.hexFloatString2decimalFloatString(CUHD9));
		index += 8;
		//A 相电压HD11
		String AUHD11 = upLoadData.substring(index, index + 8);
		result.setAUHD11(NumberDataConvertUtils.hexFloatString2decimalFloatString(AUHD11));
		index += 8;
		//B 相电压HD11
		String BUHD11 = upLoadData.substring(index, index + 8);
		result.setBUHD11(NumberDataConvertUtils.hexFloatString2decimalFloatString(BUHD11));
		index += 8;
		//C 相电压HD11
		String CUHD11 = upLoadData.substring(index, index + 8);
		result.setCUHD11(NumberDataConvertUtils.hexFloatString2decimalFloatString(CUHD11));
		index += 8;
		/** 电流 **/
		//A 相电流HD3
		String AIHD3 = upLoadData.substring(index, index + 8);
		result.setAIHD3(NumberDataConvertUtils.hexFloatString2decimalFloatString(AIHD3));
		index += 8;
		//B 相电流HD3
		String BIHD3 = upLoadData.substring(index, index + 8);
		result.setBIHD3(NumberDataConvertUtils.hexFloatString2decimalFloatString(BIHD3));
		index += 8;
		//C 相电流HD3
		String CIHD3 = upLoadData.substring(index, index + 8);
		result.setCIHD3(NumberDataConvertUtils.hexFloatString2decimalFloatString(CIHD3));
		index += 8;
		//A 相电流HD5
		String AIHD5 = upLoadData.substring(index, index + 8);
		result.setAIHD5(NumberDataConvertUtils.hexFloatString2decimalFloatString(AIHD5));
		index += 8;
		//B 相电流HD5
		String BIHD5 = upLoadData.substring(index, index + 8);
		result.setBIHD5(NumberDataConvertUtils.hexFloatString2decimalFloatString(BIHD5));
		index += 8;
		//C 相电流HD5
		String CIHD5 = upLoadData.substring(index, index + 8);
		result.setCIHD5(NumberDataConvertUtils.hexFloatString2decimalFloatString(CIHD5));
		index += 8;
		//A 相电流HD7
		String AIHD7 = upLoadData.substring(index, index + 8);
		result.setAIHD7(NumberDataConvertUtils.hexFloatString2decimalFloatString(AIHD7));
		index += 8;
		//B 相电流HD7
		String BIHD7 = upLoadData.substring(index, index + 8);
		result.setBIHD7(NumberDataConvertUtils.hexFloatString2decimalFloatString(BIHD7));
		index += 8;
		//C 相电流HD7
		String CIHD7 = upLoadData.substring(index, index + 8);
		result.setCIHD7(NumberDataConvertUtils.hexFloatString2decimalFloatString(CIHD7));
		index += 8;
		//A 相电流HD9
		String AIHD9 = upLoadData.substring(index, index + 8);
		result.setAIHD9(NumberDataConvertUtils.hexFloatString2decimalFloatString(AIHD9));
		index += 8;
		//B 相电流HD9
		String BIHD9 = upLoadData.substring(index, index + 8);
		result.setBIHD9(NumberDataConvertUtils.hexFloatString2decimalFloatString(BIHD9));
		index += 8;
		//C 相电流HD9
		String CIHD9 = upLoadData.substring(index, index + 8);
		result.setCIHD9(NumberDataConvertUtils.hexFloatString2decimalFloatString(CIHD9));
		index += 8;
		//A 相电流HD11
		String AIHD11 = upLoadData.substring(index, index + 8);
		result.setAIHD11(NumberDataConvertUtils.hexFloatString2decimalFloatString(AIHD11));
		index += 8;
		//B 相电流HD11
		String BIHD11 = upLoadData.substring(index, index + 8);
		result.setBIHD11(NumberDataConvertUtils.hexFloatString2decimalFloatString(BIHD11));
		index += 8;
		//C 相电流HD11
		String CIHD11 = upLoadData.substring(index, index + 8);
		result.setCIHD11(NumberDataConvertUtils.hexFloatString2decimalFloatString(CIHD11));
		index += 8;
		
		return result;
	}

}
